#include "trim.h"

#define IS_SPACE(c) ((c) ==' ' || (c) == '\t' || (c) == '\r' || (c) == '\n')

char * trim( char *str )
{
    char * head, *tail;
    for(head = str, tail = str; *str; str++) {
        if (!IS_SPACE(*str)) {
            tail = str + 1;
            if (IS_SPACE(*head)) {
                head = str;
            }
        }
    }
    *tail = 0;
    return head;
}
